{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第三步，对活动进行聚类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn import metrics "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import scipy.io as sio\n",
    "eventCountMatrix = sio.mmread(\"EV_eventCountMatix\") \n",
    "##mmread：Reads the contents of a Matrix Market file-like ‘source’ into a matrix."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.cluster import MiniBatchKMeans\n",
    "\n",
    "def K_cluseter_analysis(K,df): #定义可在循环里执行聚类的函数\n",
    "    print (\"K-means begin with clusters : {}\".format(K));\n",
    "    \n",
    "    km = MiniBatchKMeans(n_clusters = K)\n",
    "    km.fit(df)\n",
    "    \n",
    "    cluster_result = km.predict(df)\n",
    "    \n",
    "    CH_score = metrics.silhouette_score(df,cluster_result)\n",
    "    print(\"CH_score:{}\".format(CH_score))\n",
    "    \n",
    "    return CH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters : 10\n",
      "CH_score:0.13239945705415307\n",
      "K-means begin with clusters : 20\n",
      "CH_score:0.1524981639082216\n",
      "K-means begin with clusters : 30\n",
      "CH_score:0.15102341226444263\n",
      "K-means begin with clusters : 40\n",
      "CH_score:0.16203544437191747\n",
      "K-means begin with clusters : 50\n",
      "CH_score:0.14161629404283005\n",
      "K-means begin with clusters : 60\n",
      "CH_score:0.1342291159861917\n",
      "K-means begin with clusters : 70\n",
      "CH_score:0.14666549204490456\n",
      "K-means begin with clusters : 80\n",
      "CH_score:0.13729527614298673\n",
      "K-means begin with clusters : 90\n",
      "CH_score:0.12313850782809263\n",
      "K-means begin with clusters : 100\n",
      "CH_score:0.09291723067294187\n"
     ]
    }
   ],
   "source": [
    "CH_score = []\n",
    "Ks = [10,20,30,40,50,60,70,80,90,100]\n",
    "for K in Ks:\n",
    "    ch = K_cluseter_analysis(K,eventCountMatrix)\n",
    "    CH_score.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.13239945705415307,\n",
       " 0.1524981639082216,\n",
       " 0.15102341226444263,\n",
       " 0.16203544437191747,\n",
       " 0.14161629404283005,\n",
       " 0.13422911598619169,\n",
       " 0.14666549204490456,\n",
       " 0.13729527614298673,\n",
       " 0.12313850782809263,\n",
       " 0.092917230672941872]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "CH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f2dc0a63f98>]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xt4VPW1//H3EghYLWqBihoUPEWF\nthY10iqCWAWhtWArqKAVxGAvh2qteqooXqB6xPv1+FMQxBZERRTQVsBrpbWWABVFLlIKErGY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otlib.figure.Figure at 0x7f2dc0d449e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(Ks,np.array(CH_score),'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "此处40为Ks最佳"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
